import {HTTP} from '../utils/http.js'
const app = getApp()
class UserModel extends HTTP {
  saveUserInfo(user,collback){
    wx.login({
      success: (res) => {
        var data = {
          userCode: res.code,
          userImageUrl: user.avatarUrl,
          userName: user.nickName
        };
        this.request({
          url: app.globalData.appurl + "/qinqiang/user",
          data: data,
          success: (res) =>{
            //就保存/更新用户信息信息 不做任何操作 
            console.log(res)
            //如果想拿到回调信息 传个回调函数进来即可
            wx.setStorageSync('tekon', res.data.token)
            wx.setStorageSync('userInfo', res.data.user)
            if (collback){
              collback(res)
            }
          } 
        })
      }
    })
  }
}
export { UserModel }